/**
*      author: Y_Yao
*      created: 2024-09-14 20:56:59
**/

#include<bits/stdc++.h>

using namespace std;
const int N = 500 + 10;

void solve()
{
    char nums[N][4];

    int n = 0;
    cin >> n;
    getchar();
    for(int i =0;i < n;i++)
    {
        for(int j =0;j < 4;j++)
        {
            cin >> nums[i][j];
        }
    }

    for(int i = n - 1;i >= 0;i--)
    {
        for(int j =0;j < 4;j++)
        {
            if(nums[i][j] == '#')
            {
                cout<<j + 1<<" ";
            }
        }
    }
    cout<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 0;
    cin >> t;
    //t = 1;
    while(t--)
    {
        solve();
    }
    return 0;   
}